package Day06;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.Arrays;
import java.util.Random;

public class MethodDemo {
    public static void main(String[] args) {


        say();
        say("张三");
        say("lisi", 70);
        //say(3.14);,编译错误，无double类型参数


        int a = sum(5, 6);//sum（5，6）的值就是return后的那个数
        System.out.println(a);//11---模拟对返回值的后续操作

        int m = 5, n = 6;
        int b = sum(m, n);//传的是m和n里面的数值
        System.out.println(b);//11---模拟对返回值的后续操作


        int[] c = generateArray(5, 400);
        for (int i = 0; i < c.length; i++) {
            System.out.println(c[i]);
        }

        int[] d = generateArray(6, 700);
        System.out.println("第一个元素的值：" + d[0]);
        Arrays.sort(d);
        for (int i = 0; i < d.length; i++) {
            System.out.println(d[i]);
        }


    }


    public static void say(String name, int age) {     //形参
        if (age >= 60) {//在某种特定条件下，提前结束方法
            //break;//结束方法
        }
        System.out.println("你好，我叫" + name + "年龄" + age + "岁了");

    }


    public static int sum(int nun1, int num2) {//有参，有返回值
        int num = nun1 + num2;
        return num;//返回的是num里面的那个数
    }


    public static void say() {
        System.out.println("hello");
    }//形参


    public static void say(String name) {//形参
        System.out.println("你好，我叫" + name);
    }


    //生成一个整型数组，并填充随机数据
    public static int[] generateArray(int len, int max) {
        Random random = new Random();
        int[] a = new int[len];
        for (int b = 0; b < a.length; b++) {
            a[b] = random.nextInt(max + 1);
        }
        return a;
    }



















//overloading  方法的重载
    public static void say(int age){}//正确的重载
    public static void say(int age,String name){}//正确的重载
    //public static int say(){return 1;}   编译错误，重载与返回值类型无关
    //public static void say(String address){}  编译错误，重载与参数名称无关



























}
